package midas.mw.crt.interfaces;

import midas.mw.crt.common.IPMessage;

/**
 * CRTCallback defines the methods to be implemented by other MIDAS components
 * or external applications using the CRT. 
 * The CRT will not be directly accessible by the applications, so through these
 * functions the CRT will be able of communicating asynchronously with other 
 * components or applications.
 */
public interface CrtCallback
{
	/**
	 * This method has to be implemented to receive MIDAS messages.
	 * 
	 * @param ipMessage Object containing all the necessary information to 
	 * 			process the message.
	 */
	public void processIncomingMessage(IPMessage ipMessage);
	
	/**
	 * This method has to be implemented to receive notifications about the
	 * impossibility of delivering a message to the recipient.
	 * 
	 * @param ipMessage Object containing all the necessary information about 
	 * 			the undelivered message
	 */
	public void processUndeliveredMessage(IPMessage ipMessage);
	
	/**
	 * This method has to be implemented to receive notifications about the 
	 * delivery of a message.
	 * 
	 * @param ipMessage Object containing all the necessary information about 
	 * 			the delivered Message
	 */
	public void processDeliveredMessage(IPMessage ipMessage);
	
	/**
	 * This method has to be implemented to receive notifications about the 
	 * availability of a node in the network.
	 * 
	 * @param nodeId MIDAS node identifier .
	 * @param status Status of node. true if the node is in the network, false
	 *  		otherwise
	 */
	public void processNodePresence(String nodeId, boolean status);
	
	/**
	 * Receives a Context Based message.
	 * @param b Payload of a received context addressed message
	 */
	public void onReceivedMessage(byte b[]);
}
